﻿/////////////////////////////////////////////////////////////////
//
// Physics Helper XAML
//
// by Andy Beaulieu - http://www.andybeaulieu.com
//
// LICENSE: This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ANY 
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
/////////////////////////////////////////////////////////////////
using System;
using System.Net;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Shapes;
using System.Collections.Generic;
using FarseerPhysics.Dynamics.Contacts;

namespace Spritehand.FarseerHelper
{
    /// <summary>
    /// Defines an instance of a collision between two sprites.
    /// It is necessary to cache collisions until the end of the Simulator's Step.
    /// </summary>
    public class CollisionInstance
    {
        public PhysicsSprite Sprite1 { get; set; }
        public PhysicsSprite Sprite2 { get; set; }
        public Contact Contact { get; set; }

        public CollisionInstance(PhysicsSprite sprite1, PhysicsSprite sprite2, Contact contact)
        {
            Sprite1 = sprite1;
            Sprite2 = sprite2;
            Contact = contact;
        }
    }

    /// <summary>
    /// This will keep a list of collisions for a step.
    /// </summary>
    public static class CollisionStore
    {
        public static List<CollisionInstance> Collisions = new List<CollisionInstance>();

        public static void AddCollision(PhysicsSprite sprite1, PhysicsSprite sprite2, Contact contact)
        {
            Collisions.Add(new CollisionInstance(sprite1, sprite2, contact));
        }

    }
}
